﻿using GameLogic.Poker;

namespace GameLogic
{
    public class Card
    {
        
        public Rang  Rang { get; set; }
        public Suit Suit { get; set; }
        public State State { get; set; }

        public Card(Rang rang,Suit suit)
        {
            State = State.Down;
            Rang = rang;
            Suit = suit;
        }

        protected bool Equals(Card other)
        {
            return Rang.Equals(other.Rang) && Suit.Equals(other.Suit) && State.Equals(other.State);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != this.GetType()) return false;
            return Equals((Card) obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                int hashCode = Rang.GetHashCode();
                hashCode = (hashCode*397) ^ Suit.GetHashCode();
                hashCode = (hashCode*397) ^ State.GetHashCode();
                return hashCode;
            }
        }

        public static bool operator ==(Card left, Card right)
        {
            return Equals(left, right);
        }

        public static bool operator !=(Card left, Card right)
        {
            return !Equals(left, right);
        }
    }
}